package com.credithc.signature.facade.facadeenum;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 描述：响应枚举类<br/>
 * 作者：sunyang
 * 创建：2019/5/28 14:55
 * 版本：v1.0.0<br/>
 */
public enum ResponseEnum {

    /**
     * 投递请求成功
     */
    SUCCESS(0, "投递请求成功"),

    /**
     * 投递请求失败
     */
    FAIL(-1, "投递请求失败"),

    /**
     * 非法渠道
     */
    ILLEGAL_CHANNEL(-2, "非法渠道"),

    /**
     * 非法模板
     */
    ILLEGAL_TEMPLATE(-3, "非法模板"),

    /**
     * 非法公章
     */
    ILLEGAL_OFFICIAL_SEAL(-4, "非法公章"),

    /**
     * 手写图片大小超过限制
     */
    ILLEGAL_HANDWRITING_IMAGE(-5, "手写图片大小超过限制");


    private int code;

    private String message;

    private static volatile Map<Integer, String> map = initMap();

    ResponseEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Map<Integer, String> ofMap() {
        return map;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    private static Map<Integer, String> initMap() {
        ResponseEnum[] values = ResponseEnum.values();
        Map<Integer, String> map = Maps.newHashMapWithExpectedSize(values.length);
        for (ResponseEnum responseEnum : values) {
            map.put(responseEnum.getCode(), responseEnum.getMessage());
        }
        return map;
    }

}
